<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>

<head>
</head>
<style>
</style>

<body>
	<div id="leg_table"></div>
	<script type="text/html" id="stateListBar">
			<a class="mui-btn mui-btn-primary edit">编辑</a>
			<a class="mui-btn mui-btn-primary del">删除</a>
		</script>
	<script type="text/javascript">
			mui('#offCanvasContentScroll').scroll().scrollTo(0,0);
			
			$(".mui-title").html("管理员列表")
			
			//接收数据
			var stateList = $.legTable({
				limit: 10,			//默认10
				page:1,				//默认1
				id:"#leg_table",	//绑定id
				url:"/main/getManagerList",
				cols:[
					    {field: 'loginName', title: '登录用户'},
			            {field: 'realName', title: '真实名字'},
			            {field: 'mobilePhone', title: '手机号'},
			            {field: 'compName', title: '公司'},
			            {field: 'email', title: '电子邮箱'},
			            {field: 'roleName', title: '权限名称'},
			            {field: 'formUserName', title: '绑定的微信号'},
			            {title: '操作', templet:'#stateListBar'}
		        ]
			});
			
			//编辑
			$("#leg_table").on("touchstart", ".table-list .edit", function(e){
			 	let i = $(this).parent('data').attr("value");
				let url = "/managerEdit/index?roleId="+$.data(i).roleId;
				window.location.hash = url;
				sessionStorage.setItem("url",url)
				sessionStorage.setItem("admin",JSON.stringify($.data(i)))
		    });
			
			//添加
			$("#Add").show();
			$("#Add").on("touchstart",function(e){
				$("#Add").hide();
				url = "/managerAdd/index";
				window.location.href = url;
			})
           //删除
           $("#leg_table").on("touchstart", ".table-list .del", function(e){
        	    let i = $(this).parent('data').attr("value");

				mui.confirm('确定删除此账户？','温馨提示',function(e) {
					if (e.index == 1) {
						$.get("/main/deleteUser?managerId="+$.data(i).managerId,function(res){
			           		if (!res.success) {
			           			mui.toast(res.message);
			       			}else{
			       				mui.toast("删除成功");
			       				stateList = $.legTable();
			       			}
			           	})
					}
				})
            })
			
		</script>
</body>

</html>